package com.java110.mall.cart.dao.impl;

import com.java110.mall.cart.dao.IStoreStatisticsServiceDao;
import com.java110.core.base.dao.BaseServiceDao;
import com.java110.dto.mallReport.MallReportDto;
import com.java110.utils.exception.DAOException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * 订单购物车服务 与数据库交互
 * Created by wuxw on 2017/4/5.
 */
@Service("storeStatisticsServiceDaoImpl")
//@Transactional
public class StoreStatisticsServiceDaoImpl extends BaseServiceDao implements IStoreStatisticsServiceDao {

    private static Logger logger = LoggerFactory.getLogger(StoreStatisticsServiceDaoImpl.class);


    /**
     * 查询进货统计 到 instance
     *
     * @param info bId 信息
     * @throws DAOException DAO异常
     */
    @Override
    public List<Map> getInStockInfo(Map info) throws DAOException {
        logger.debug("查询进货统计 入参 info : {}", info);

        List<Map> inStockInfos = sqlSessionTemplate.selectList("storeStatisticsServiceDaoImpl.getInStockInfo", info);

        return inStockInfos;
    }

    /**
     * 查询挂单数量
     * @param info 挂单信息
     * @return 挂单数量
     */
    @Override
    public int getInStockInfoCount(Map info) {
        logger.debug("查询进货统计数据 入参 info : {}",info);

        List<Map> businessStoreOrderUpInfos = sqlSessionTemplate.selectList("storeStatisticsServiceDaoImpl.getInStockInfoCount", info);
        if (businessStoreOrderUpInfos.size() < 1) {
            return 0;
        }

        return Integer.parseInt(businessStoreOrderUpInfos.get(0).get("count").toString());
    }


    /**
     * 查询进货统计 到 instance
     *
     * @param info bId 信息
     * @throws DAOException DAO异常
     */
    @Override
    public List<Map> getSalesInfo(Map info) throws DAOException {
        logger.debug("查询销售统计 入参 info : {}", info);

        List<Map> inStockInfos = sqlSessionTemplate.selectList("storeStatisticsServiceDaoImpl.getSalesInfo", info);

        return inStockInfos;
    }

    /**
     * 查询挂单数量
     * @param info 挂单信息
     * @return 挂单数量
     */
    @Override
    public int getSalesInfoCount(Map info) {
        logger.debug("查询销售统计数据 入参 info : {}",info);

        List<Map> businessStoreOrderUpInfos = sqlSessionTemplate.selectList("storeStatisticsServiceDaoImpl.getSalesInfoCount", info);
        if (businessStoreOrderUpInfos.size() < 1) {
            return 0;
        }

        return Integer.parseInt(businessStoreOrderUpInfos.get(0).get("count").toString());
    }


    /**
     * 查询进货统计 到 instance
     *
     * @param info bId 信息
     * @throws DAOException DAO异常
     */
    @Override
    public List<Map> getInoutInfo(Map info) throws DAOException {
        logger.debug("查询进货统计 入参 info : {}", info);

        List<Map> inStockInfos = sqlSessionTemplate.selectList("storeStatisticsServiceDaoImpl.getInoutInfo", info);

        return inStockInfos;
    }

    /**
     * 查询挂单数量
     * @param info 挂单信息
     * @return 挂单数量
     */
    @Override
    public int getInoutInfoCount(Map info) {
        logger.debug("查询进货统计数据 入参 info : {}",info);

        List<Map> businessStoreOrderUpInfos = sqlSessionTemplate.selectList("storeStatisticsServiceDaoImpl.getInoutInfoCount", info);
        if (businessStoreOrderUpInfos.size() < 1) {
            return 0;
        }

        return Integer.parseInt(businessStoreOrderUpInfos.get(0).get("count").toString());
    }


    /**
     * 查询进货统计 到 instance
     *
     * @param info bId 信息
     * @throws DAOException DAO异常
     */
    @Override
    public List<Map> getSalesRankingInfo(Map info) throws DAOException {
        logger.debug("查询进货统计 入参 info : {}", info);

        List<Map> inStockInfos = sqlSessionTemplate.selectList("storeStatisticsServiceDaoImpl.getSalesRankingInfo", info);

        return inStockInfos;
    }

    /**
     * 查询挂单数量
     * @param info 挂单信息
     * @return 挂单数量
     */
    @Override
    public int getSalesRankingInfoCount(Map info) {
        logger.debug("查询进货统计数据 入参 info : {}",info);

        List<Map> businessStoreOrderUpInfos = sqlSessionTemplate.selectList("storeStatisticsServiceDaoImpl.getSalesRankingInfoCount", info);
        if (businessStoreOrderUpInfos.size() < 1) {
            return 0;
        }

        return Integer.parseInt(businessStoreOrderUpInfos.get(0).get("count").toString());
    }

    /**
     * 查询进货统计 到 instance
     *
     * @param info bId 信息
     * @throws DAOException DAO异常
     */
    @Override
    public List<Map> getSellingCost(Map info) throws DAOException {
        logger.debug("查询进货统计 入参 info : {}", info);

        List<Map> inStockInfos = sqlSessionTemplate.selectList("storeStatisticsServiceDaoImpl.getSellingCost", info);

        return inStockInfos;
    }

    /**
     * 查询挂单数量
     * @param info 挂单信息
     * @return 挂单数量
     */
    @Override
    public int getSellingCostCount(Map info) {
        logger.debug("查询进货统计数据 入参 info : {}",info);

        List<Map> businessStoreOrderUpInfos = sqlSessionTemplate.selectList("storeStatisticsServiceDaoImpl.getSellingCostCount", info);
        if (businessStoreOrderUpInfos.size() < 1) {
            return 0;
        }

        return Integer.parseInt(businessStoreOrderUpInfos.get(0).get("count").toString());
    }

    /**
     * 查询进货统计 到 instance
     *
     * @param info bId 信息
     * @throws DAOException DAO异常
     */
    @Override
    public List<Map> getSellingCostDetail(Map info) throws DAOException {
        logger.debug("查询进货统计 入参 info : {}", info);

        List<Map> inStockInfos = sqlSessionTemplate.selectList("storeStatisticsServiceDaoImpl.getSellingCostDetail", info);

        return inStockInfos;
    }

    /**
     * 查询挂单数量
     * @param info 挂单信息
     * @return 挂单数量
     */
    @Override
    public int getSellingCostDetailCount(Map info) {
        logger.debug("查询进货统计数据 入参 info : {}",info);

        List<Map> businessStoreOrderUpInfos = sqlSessionTemplate.selectList("storeStatisticsServiceDaoImpl.getSellingCostDetailCount", info);
        if (businessStoreOrderUpInfos.size() < 1) {
            return 0;
        }

        return Integer.parseInt(businessStoreOrderUpInfos.get(0).get("count").toString());
    }
}
